#!/bin/bash -ex

CMAKE_SCRIPT_DIR="$(realpath $(dirname ${0}))"
SCRIPT_DIR="$(dirname ${CMAKE_SCRIPT_DIR})"
ROOT_REPO_DIR="$(dirname ${SCRIPT_DIR})"

BUILD_DIR="${ROOT_REPO_DIR}/build"
mkdir -p "${BUILD_DIR}"

BUILD_PANDA_DIR="${1:-/home/aleks/build_dirs/panda_sdks_buids/sdk_host_relwithdebinfo/linux_host_tools}"

cd "${BUILD_DIR}"

rm -rf *
cmake \
"${ROOT_REPO_DIR}/CMakeLists.txt" \
-GNinja -B "${BUILD_DIR}" \
-DBUILD_PANDA_PATH="${BUILD_PANDA_DIR}" \
-DUSE_LOCAL_BUILD_PANDA=ON
